Skip to content

fix: warn when onboarding is run outside a Capacitor project#570

Merged
WcaleNieWolny merged 1 commit intomainfrom
fix/warn-non-capacitor-project
Mar 24, 2026
Merged

fix: warn when onboarding is run outside a Capacitor project#570
WcaleNieWolny merged 1 commit intomainfrom
fix/warn-non-capacitor-project

Conversation

@WcaleNieWolny
Copy link
Copy Markdown
Contributor

@WcaleNieWolny WcaleNieWolny commented Mar 24, 2026

Summary

  • Warn and prompt to exit if no capacitor.config.* is found in the current directory
  • Warn and prompt if no native platform directories (ios/android) exist, respecting custom paths from ios.path/android.path in capacitor config
  • Reword install/import step prompts to be human-friendly ("Install @capgo/capacitor-updater in your project?" instead of "Automatic Install ... dependency in com.example.app?")
  • Convert confirm prompts to selects with emoji labels (✅/❌) for consistency with other onboarding steps

Test plan

  • Run node dist/index.js i from a non-Capacitor directory — should warn and offer to exit
  • Run from a Capacitor project without ios/android dirs — should warn and ask to continue
  • Run from a full Capacitor project with ios/ — no warnings shown
  • Install updater step shows "Install @capgo/capacitor-updater in your project?" with emoji options
  • Add code step shows "Add the Capacitor Updater import to your main file?" with emoji options

Summary by CodeRabbit

  • New Features
    • Enhanced initialization prompts with choice-based options (e.g., "install" vs "manual") for better clarity during package and code setup.
    • Added configuration file validation to ensure Capacitor setup is detected before proceeding.
    • Added native platform directory detection (iOS/Android) with user prompts when directories are missing.

- Warn and prompt to exit if no capacitor.config.* is found in the
  current directory
- Warn and prompt if no native platform directories (ios/android) exist,
  respecting custom paths from capacitor config (ios.path/android.path)
- Reword install/import prompts to be clearer
- Convert confirm prompts to selects with emoji labels for consistency
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR modifies the initialization command to replace confirmation prompts with choice-based selections for package installation and code injection, and adds preflight validation checks for Capacitor configuration and native platform directories during app initialization.

Changes

Cohort / File(s) Summary
Interactive Initialization UX
src/init/command.ts
Replaced confirmation prompts with pSelect choice-based prompts for installing @capgo/capacitor-updater (offering "install" vs "manual") and auto-adding Capacitor Updater imports (offering "add it" vs "manual"), with conditional execution gated on selected choice values.
Preflight Validation
src/init/command.ts
Added validation logic to initApp that detects whether a capacitor.config.* file exists, warns if missing, and checks for expected native platform directories (ios, android) when config is present, with user prompts to continue or exit at each validation step.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through init's bright halls,
Now asking choice, not just a call,
"Config found?" it checks with care,
Platform paths? We'll see if there!
Validation done, the path grows clear,
Initialization blooms, oh dear!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the main change: adding validation and warnings when onboarding is run outside a Capacitor project, with checks for capacitor.config and native platform directories.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/warn-non-capacitor-project

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

@WcaleNieWolny WcaleNieWolny merged commit 919e6f0 into main Mar 24, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant